package com.example.cloudindex.web.feign;

import com.example.cloudindex.bean.User;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.cloud.openfeign.SpringQueryMap;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

@FeignClient(value = "cloud-order", fallback = OrderActionImpl.class)
public interface OrderAction {

    @RequestMapping("order")
    public String order();

    @RequestMapping("hello")
    public String hello(@RequestParam String name);

    @RequestMapping("add")
    public int add(@RequestParam int a, @RequestParam int b);

    @RequestMapping("my/{name}")
    public String myname(@PathVariable String name);

    @RequestMapping("showUserByBody")
    public User displayUser(@RequestBody User user);

    @RequestMapping("showUserByParam")
    public User showUser(@SpringQueryMap User user);

    // 1. 路径参数: my/{name}
    // 2. 地址参数: xx?name=xxx&age=xxx
    // 3. 请求体参数: body

    /**
     * Feign 传参
     * 1. 简单参数 => 地址参数 => @RequestParam
     * 2. 对象参数 => body参数 => @RequestBody
     * 3. 对象参数 => 地址参数  => @SpringQueryMap
     * 4. 路径参数 => 路径参数  => @PathVarible
     * 5. 多个对象参数 => 组合成一个对象参数 => 同 2, 3
     */

}
